def max_subarray_sum(nums):
    if not nums:
        return 0

    current_max = global_max = nums[0]
    for num in nums[1:]:
        current_max = max(num, current_max + num)
        global_max = max(global_max, current_max)
    return global_max

try:
    input_str = input("请输入整数数组（元素之间用空格分隔）：")
    nums = list(map(int, input_str.split()))
    result = max_subarray_sum(nums)
    print(f"子数组之和的最大值为：{result}")
except ValueError:
    print("输入格式错误，请确保输入的是整数且用空格分隔！")